#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int lengthOfLastWord(string s)
    {
        int res = 0;
        bool flag = false;
        for (int i = s.size() - 1;i >= 0;--i)
        {
            if (isalpha(s[i]))
            {
                flag = true;
            }
            else if (flag == true)
            {
                break;
            }
            if (flag)
            {
                ++res;
            }
        }
        return res;
    }
};